package android.medicalcloud.com.yiapp.yilian.ui.view.adapter;

import android.content.Context;
import android.graphics.Color;
import android.medicalcloud.com.yiapp.R;
import android.medicalcloud.com.yiapp.base.adapter.BasePlatAdapter;
import android.medicalcloud.com.yiapp.yilian.configer.enums.OrderStatus;
import android.medicalcloud.com.yiapp.yilian.model.OrderModel;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

/**
 * Created by wanggenlin on 17-5-18.
 */
public class OderItemAdapter extends BasePlatAdapter <OrderModel>{
    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        if (convertView==null){
            convertView = mLayoutInflater.inflate(R.layout.adapter_order_item,parent,false);
        }
       TextView codeTv = (TextView) convertView.findViewById(R.id.codeTv);
       TextView hospitalTv = (TextView) convertView.findViewById(R.id.hospitalTv);
       TextView timeTV = (TextView) convertView.findViewById(R.id.timeTV);
       TextView stauesTv = (TextView) convertView.findViewById(R.id.stauesTv);
       ImageView typeIv = (ImageView) convertView.findViewById(R.id.typeIv);
        codeTv.setText("订单编号："+getItem(position).getCode());
        hospitalTv.setText("邀请医院："+getItem(position).getYiyuan());
        timeTV.setText("会诊时间："+getItem(position).getConsultationStartTime());
        try {
            stauesTv.setText(OrderStatus.getShowText(Integer.parseInt(getItem(position).getStaus())));
            stauesTv.setTextColor(Color.parseColor("#727d8b"));
            if (Integer.parseInt(getItem(position).getStaus())==209){
                stauesTv.setTextColor(Color.parseColor("#29ab91"));
            }
            if (Integer.parseInt(getItem(position).getStaus())==206||Integer.parseInt(getItem(position).getStaus())==203){
                stauesTv.setTextColor(Color.parseColor("#f15a4a"));
            }
        }catch (Exception e){

        }

        if (getItem(position).getType().equals("100")){
            typeIv.setImageResource(R.drawable.write);
        }else{
            typeIv.setImageResource(R.drawable.listen);
        }
        return convertView;
    }
    public OderItemAdapter(Context context) {
        super(context);
    }
}
